using System;
using System.IO;
using System.Reflection;
using NUnit.Framework;
using SQLRunnerLib.VersionCheck;
using SQLTests.Framework;

namespace SQLTests.Version.URL
{
	/// <summary>
	/// Summary description for URLCheckerTests.
	/// </summary>
	public class URLCheckerTests:
			AbstractTest
	{
		private SQLRunnerVersion _version = new SQLRunnerVersion();

        // Moved to SQLUnitTests
        //[Test]
        //public void CheckSerialization()
        //{
        //    _version.Serialize(@"C:\Version.xml");
        //    SQLRunnerVersion version = SQLRunnerVersion.Deserialize(@"C:\Version.xml");
        //    Assert.IsTrue(
        //        version.Version.CompareTo(_version.Version) == 0);
        //}

        // Duplicate of above test moved to SQLUnitTests
        //[Test]
        //public void CheckIsSameVersion()
        //{
        //    _version.Serialize(@"C:\Version.xml");
        //    SQLRunnerVersion version = SQLRunnerVersion.Deserialize(@"C:\Version.xml");
        //    Assert.IsTrue(
        //        version.Version.CompareTo(_version.Version) == 0);	
        //}

        // Moved to SQLUnitTests
        //[Test]
        //public void CheckIsHigherVersion()
        //{
        //    _version.Serialize(@"C:\Version.xml");
        //    SQLRunnerVersion version = SQLRunnerVersion.Deserialize(@"C:\Version.xml");
        //    version.Version.Minor++;
        //    Assert.IsTrue(
        //        version.Version.CompareTo(_version.Version) > 0);	
        //}

        // Moved to SQLUnitTests
        //[Test]
        //public void CheckIsLowerVersion()
        //{
        //    _version.Serialize(@"C:\Version.xml");
        //    SQLRunnerVersion version = SQLRunnerVersion.Deserialize(@"C:\Version.xml");
        //    version.Version.Revision--;
        //    Assert.IsTrue(
        //        version.Version.CompareTo(_version.Version) < 0);	
        //}

		[Test]
		public void CheckFullVersion()
		{
			Assert.AreEqual("1.2.0.1", _version.Version.ToString());
		}

		[Test]
		public void CheckVersion()
		{
			AppVersion currVer = new AppVersion();
			System.Version version = Assembly.GetExecutingAssembly().GetName().Version;
			currVer.Major = version.Major; currVer.Minor = version.Minor; 
			currVer.Revision = currVer.Revision; currVer.Build = version.Build; 
		}

		[TestFixtureSetUp]
		protected override void SetUpFixtures()
		{
			_version = new SQLRunnerVersion();
			_version.MsiUrl = @"http://www.xtreme-simplicity.net/renameMemberBefore.gif";
			System.Version ver = new System.Version(1, 2, 0, 1);
			_version.Version = AppVersion.ConvertFromSystemVersion(ver);
			_version.LinkText = "www.lava-monkey.com";
		}
	}
}
